<!-- 秒杀列表 -->
<template>
  <view class="page_box seckill-list-wrap">
    <!-- 导航栏 -->
    <shopro-navbar isOrder="3" :isBack="true" :backIconColor="'#fff'" :background="background">
      <view class="u-flex-1 u-flex u-col-center" slot="content">
<!--        <image class="auto-login-img login-img" src="https://duomi.bigchun.com/images/logo.jpg"></image>-->
        <view style="color:#ffffff; width: 100%;text-align: center">多米惠选</view>
      </view>
    </shopro-navbar>
    <!-- 顶部商品 -->
    <view class="tab-box">
      <view class="money">￥{{money}}元</view>
    </view>
    <!-- dianpu  -->
    <view class="content_box">
      <view class="shop u-flex  u-col-center">
        <view class="shopimg">
          <image class="shopimgs" :src="shop_image"></image>
        </view>
        <view class="shopname u-flex u-flex-col ">
          <view class="shoptitle">{{ shop_name }}</view>
          <view class="shopaddres">{{ address }}</view>
        </view>
      </view>
      <button class="seckill-btn" v-if="is_new"  @click="isdisableds?clickyouhuiquan():''">立即领取</button>
      <button class="seckill-btn btn-disabled" v-else>不符合领取条件</button>
    </view>
  </view>
</template>

<script>
import {
  mapMutations,
  mapActions,
  mapState,
  mapGetters
} from 'vuex';
export default {
  components: {},
  props:{

  },
  data() {
    return {
      background: {'background':"#b2150e"},
      money:'',
      scene:'',
      storeShopId:'',
      act:"",
      shop_name:'',
      address:'',
      is_new:'',
      shop_image:'',
      isdisableds:true
    };
  },
  onReady(){

  },
  onLoad(options) {
    if(options){
      this.scene = decodeURIComponent(options.scene)
    }
  },
  computed: {
    ...mapGetters(['isLogin']),
  },
  created(){
    if(!this.scene){
      this.scene = this.$Route.query.scene;
    }
    console.log("==this.scene",this.$Route,this.scene)
    if(!uni.getStorageSync("storeShopId")){
      let arr =  this.scene.split("&");
      let arr1 =  arr[0].split("=")[1];
      this.storeShopId = arr1;
      uni.setStorageSync("storeShopId",this.storeShopId)
    }else{
      this.storeShopId = uni.getStorageSync("storeShopId")
    }
    if(!this.isLogin){
      this.$store.dispatch('showAuthModal','toLogins')
    }
    this.isnewuser();
    this.init();
  },
  onshow(){
  },
  methods: {
    init(){
      this.getstore();
    },
    isnewuser(){
      let that = this;
      that.$https(
          'user.isGegHongbao',
          {
            token:  uni.getStorageSync("token"),
          },
          '加载中...'
      ).then(res => {
        if (res.code === 1) {
          that.is_new = res.data.is_new;
        }else{
          that.$u.toast(res.msg);
        }
      });
    },
    //顶部商品列表
    getstore() {
      let that = this;
      that.$https(
          'user.hongbao',
          {
            store_shop_id:  that.storeShopId,
            // is_notoken:true
          },
          '加载中...'
      ).then(res => {
        if (res.code === 1) {
          that.money = res.data.youhui_money;
          that.shop_name = res.data.shop_name;
          that.address = res.data.address;
          that.is_new = res.data.is_new;
          that.shop_image = res.data.shop_image;
        }else{
          that.$u.toast(res.msg);
        }
      });
    },
    clickyouhuiquan(){
      let that = this;
      that.$https(
          'user.haibaoget',
          {
            token:uni.setStorageSync("token"),
            store_shop_id:  that.storeShopId,
          },
          '加载中...'
      ).then(res => {
        if (res.code === 1) {
          that.$u.toast(res.msg);
          this.isdisableds = false;
          uni.switchTab({
            url: `/pages/index/index`,
          })
        }else{
          that.$u.toast(res.msg);
        }
      });
    }

  }
};
</script>

<style lang="scss">

.page_box{
  height: 100vh;
  background:#F48653;
  .tab-box{
    width: 100%;
    height: 1000rpx;
    background: url('https://duomi.bigchun.com/images/Group2441.png') no-repeat;
    background-size:100%;
    .money{
      font-size: 60rpx;
      padding-top: 410rpx;
      font-family: PingFang SC-Heavy, PingFang SC;
      font-weight: 800;
      color: #FF1306;
      line-height: 45px;
      margin: 0rpx auto;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
  .content_box{
    width: 100%;
    height: 330rpx;
    background:#F48653 ;
    padding: 20rpx;
    .shop{
      width: 100%;
      height: 180rpx;
      background: #fff;
      padding: 20rpx;
      .shopimg{
        width: 104rpx;
        height: 104rpx;
        margin-right: 20rpx;
        .shopimgs{
          width: 100%;
          height: 100%;
        }
      }
      .shopname{
        width: 82%;
        height: 100%;
        align-items: initial;
        .shoptitle{
          margin-bottom: 10rpx;
          font-size: 32rpx;
          width: 100%;
          height: 45rpx;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        .shopaddres{
          width: 100%;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
        }
      }
    }
    .seckill-btn {
      width: 100%;
      line-height: 70rpx;
      color: #fff;
      background-color: #DC281A;
      font-size: 28rpx;
      font-weight: 500;
      border-radius: 35rpx;
      padding: 0;
      margin-top: 5%;
      margin-bottom: 30rpx;
    }
  }
}
.cu-bar .content{
  height: auto!important;
}
.page_box .u-flex-1 .auto-login-img{
  width: 80rpx!important;
  height: 80rpx!important;
  margin: 0 30rpx;
  border-radius: 50%;
}
.page_box .content_box .btn-disabled{
  color: #969595;
  background-color: #d8d6d6;
}
</style>
